package com.cn.coupon.service;
import com.cn.api.FrontFeignClient;
import com.cn.coupon.mapper.FrontMapper;
import com.cn.dto.CouponDTO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController("/api/front")
public class FrontService implements FrontFeignClient {

    @Resource
    private FrontMapper frontMapper;

    @PostMapping("/advertisement")//前端广告展示
    @Override
    public CouponDTO advertisement(int coupon_id) {
        return frontMapper.advertisement(coupon_id);
    }

    @PostMapping("/findAll")
    @Override
    public List<CouponDTO> findAll(CouponDTO couponDTO) {
        return frontMapper.findAll(couponDTO);
    }

    @PostMapping("/findByState")
    @Override
    public CouponDTO findByState(int state) {
        return frontMapper.findByState(state);
    }

    @PostMapping("/getCoupon")//去领取
    @Override
    public CouponDTO getCoupon(CouponDTO couponDTO) {
        return frontMapper.getCoupon(couponDTO);
    }

    @PostMapping("/receive")//领取
    @Override
    public Integer receive(int id) {
        return frontMapper.receive(id);
    }

    @PostMapping("/usedCoupon")
    @Override
    public Integer usedCoupon(int id) {
        return frontMapper.usedCoupon(id);
    }
}
